import domain.Point;
import functors.FunctorChain;
import functors.RestPointFunctor;
import functors.ThreeLineFunctor;
import util.FileUtil;
import util.ShuduUtil;

import java.util.List;


/**
 * @Author: sszheng
 * @Date: 2018/8/6 9:49
 */
public class Calculator {
    public void execute(String filename) {
        List<Point> list = init(filename);
        ShuduUtil.print(list);
        doCalc(list);
        ShuduUtil.print(list);
    }

    private void doCalc(List<Point> list) {
        FunctorChain fc = new FunctorChain();
        fc.addFunctor(new ThreeLineFunctor()).addFunctor(new RestPointFunctor());
        fc.calc(list);
    }

    private List<Point> init(String filename) {
        String txt = FileUtil.readfile(filename);
        List<Point> list = ShuduUtil.convert2List(txt);
        return list;
    }

}
